<cfcomponent displayname="userFacade" output="false" hint="userFacade component for snipEx">
	
	<cffunction name="init" access="public" output="false" returntype="userFacade" hint="Constructor for this CFC">
		<cfargument name="loginStatus" default="false" required="false" type="boolean">
		<cfargument name="snipExSessionID" default="#createUUID()#" required="false" type="string">
		<cfargument name="isAdmin" default="0" required="false" type="numeric">
		<cfargument name="isSysAdmin" default="0" required="false" type="numeric">
		<cfargument name="userid" default="#createUUID()#" required="false" type="string">
		<cfargument name="user" default="#createobject('component','snipex.model.users.users').init()#" required="false" type="any">
		
		
		<cfset setLoginStatus(arguments.loginStatus) />
		<cfset setSnipExSessionID(arguments.snipExSessionID) />
		<cfset setIsAdmin(arguments.isAdmin) />
		<cfset setIsSysAdmin(arguments.isSysAdmin) />
		<cfset setUserID(arguments.userid) />		
		<cfset setUser(arguments.user) />
		<!--- return this object --->
		<cfreturn this />
	</cffunction>
	
	<cffunction name="hasId" access="public" output="false" returntype="boolean" hint="I check to see if there is a sessionID">		

		<cfreturn structKeyExists(session,"SnipExSessionID")/>
	</cffunction>
	
	<cffunction name="clear" access="public" output="false" returntype="boolean" hint="I clear the session values">
		<cfset structDelete(session, "isSysAdmin")>
		<cfset structDelete(session, "isAdmin")>
		<cfset session.isLoggedin = false />
	</cffunction>
	
	<cffunction name="getLoginStatus" access="public" output="false" returntype="boolean" hint="Get the login status for this session">
		<cftry>
			<cfreturn Session.isLoggedIn />
			<cfcatch type="any">
				<cfreturn false />
			</cfcatch>
		</cftry>
	</cffunction>
	
	<cffunction name="setLoginStatus" access="public" output="false" returntype="void" hint="Set he login status for this session">
		<cfargument name="loginStatus" required="true" type="boolean">
		<cfset Session.isLoggedIn = arguments.loginStatus />
	</cffunction>
	
	<cffunction name="getSnipExSessionID" access="public" output="false" returntype="string" hint="Get the SnipEx SessionID  status for this session">
		<cftry>
			<cfreturn Session.SnipExSessionID />
			<cfcatch type="any">
				<cfreturn false />
			</cfcatch>
		</cftry>
	</cffunction>
	
	<cffunction name="setSnipExSessionID" access="public" output="false" returntype="void" hint="Set the SnipEx SessionID for this session">
		<cfargument name="SnipExSessionID" required="true" type="string">
		<cfset Session.SnipExSessionID = arguments.SnipExSessionID />
	</cffunction>
	
	<cffunction name="getIsAdmin" access="public" output="false" returntype="numeric" hint="Get the isAdmin flag for this session">
		<cftry>
			<cfreturn Session.isAdmin />
			<cfcatch type="any">
				<cfreturn false />
			</cfcatch>
		</cftry>
	</cffunction>
	 
	<cffunction name="setIsAdmin" access="public" output="false" returntype="void" hint="Set the isAdmin flag for this session">
		<cfargument name="isAdmin" required="true" type="numeric">
		<cfset Session.isAdmin = arguments.isAdmin />
	</cffunction>
	
	<cffunction name="getIsSysAdmin" access="public" output="false" returntype="numeric" hint="Get the isSysAdmin flag for this session">
		<cftry>
			<cfreturn Session.isSysAdmin />
			<cfcatch type="any">
				<cfreturn false />
			</cfcatch>
		</cftry>
	</cffunction>
	
	<cffunction name="setIsSysAdmin" access="public" output="false" returntype="void" hint="Set the isSysAdmin flag for this session">
		<cfargument name="issysAdmin" required="true" type="numeric">
		<cfset Session.isSysAdmin = arguments.isSysAdmin />
	</cffunction>
	
	<cffunction name="getUserID" access="public" output="false" returntype="string" hint="Get the userID for this session">
		<cftry>
			<cfreturn Session.userid />
			<cfcatch type="any">
				<cfreturn false />
			</cfcatch>
		</cftry>
	</cffunction>
	
	<cffunction name="setUserID" access="public" output="false" returntype="void" hint="Set the userid for this session">
		<cfargument name="userid" required="true" type="string">
		<cfset Session.userid = arguments.userid />
	</cffunction>
	
	<!--- Usage: Getuser / Setuser methods for user value --->
    <cffunction name="getuser" access="public" output="false" returntype="any">
       <cfreturn session.user />
    </cffunction>

    <cffunction name="setuser" access="public" output="false" returntype="void">
       <cfargument name="user" type="any" required="true" />
       <cfset session.user = arguments.user />
    </cffunction>
</cfcomponent>